Skip to content

Conversation

@devmotion
Copy link
Member

The motivation for the test is to check that out-of-place cov2cor and cor2cov of Hermitian and Symmetric matrices only write to the active triangle. But it's a bit unreliable (see e.g. https://github.com/JuliaStats/StatsBase.jl/actions/runs/18417193235?pr=965) as we don't have any control over how the output matrix is actually initialized in

return cov2cor!(copyto!(similar(C, T), C), s)
and
return cor2cov!(copyto!(similar(C, T), C), s)
.

@devmotion
Copy link
Member Author

The doctest error is fixed in #966.

@nalimilan
Copy link
Member

If we filled the parent with sufficiently random values, the probability that similar gives the same values should be super small, right?

if A isa Union{Symmetric,Hermitian}
@test fA isa (A isa Symmetric ? Symmetric : Hermitian)
@test fA.uplo == A.uplo
@test parent(fA) != fA # only active triangle is written to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's the same line in the branch above, shouldn't it be removed too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test in the branch above should be fine since it's for the in-place methods: In these cases, as tested, fA === A but since A is created by copying (and potentially wrapping) a properly initialised matrix, the parent could only be equal to the wrapped array after the cov2cor!/cor2cov! call if all standard deviations are one.

@devmotion devmotion merged commit 0341248 into master Jan 7, 2026
13 checks passed
@devmotion devmotion deleted the dw/clean_test branch January 7, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants